package dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.WindowConstants;

import video.Sender;

import client.Client;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ChatDialog extends  JFrame{
	
	private JPanel jPanel1;
	private JButton jButton1;
	private JButton jButton2;
	public JTextArea textArea;
	public JTextField textField;
	//ImageIcon icon;
    
    Client client;
    Sender sender;
    public JLabel iconLabel;

	public ChatDialog(Client theClient) {
		super();
		this.client = theClient;
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jPanel1 = new JPanel();
			}
			{
				textArea = new JTextArea();
				textArea.setText("");
				textArea.setEditable(false);
			}
			{
				textField = new JTextField();
				textField.setText("");
				textField.addActionListener(new ActionListener() {
					
					@Override
					public void actionPerformed(ActionEvent arg0) {
						// TODO Auto-generated method stub
						client.peerListener.sendTextMessage();
					}
				});
			}
			{
				iconLabel = new JLabel();
				iconLabel.setText("");
			}
			{
				jButton1 = new JButton();
				jButton1.setText("Send Text");
		        jButton1.addMouseListener(new MouseAdapter() {
		            @Override
		            public void mouseClicked(MouseEvent arg0) {
		                client.peerListener.sendTextMessage();
		            }
		        });
			}
			{
				jButton2 = new JButton();
				jButton2.setText("Send Video");
				jButton2.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent arg0) {
				      client.peerListener.sendVideo();
					}
				});
			}
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addGap(7)
				.addGroup(thisLayout.createParallelGroup()
				    .addComponent(textArea, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 364, GroupLayout.PREFERRED_SIZE)
				    .addComponent(textField, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 366, GroupLayout.PREFERRED_SIZE)
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addGap(116)
				        .addComponent(jButton1, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE)
				        .addGap(145)))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addGroup(thisLayout.createParallelGroup()
				    .addComponent(iconLabel, GroupLayout.Alignment.LEADING, 0, 400, Short.MAX_VALUE)
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 73, GroupLayout.PREFERRED_SIZE)
				        .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE)
				        .addGap(76)
				        .addComponent(jButton2, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 136, Short.MAX_VALUE)))
				.addContainerGap());
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addGap(6)
				.addGroup(thisLayout.createParallelGroup()
				    .addComponent(iconLabel, GroupLayout.Alignment.LEADING, 0, 236, Short.MAX_VALUE)
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(textArea, GroupLayout.PREFERRED_SIZE, 224, GroupLayout.PREFERRED_SIZE)
				        .addGap(12))
				    .addGroup(thisLayout.createSequentialGroup()
				        .addGap(109, 109, GroupLayout.PREFERRED_SIZE)
				        .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE)
				        .addGap(117, 117, GroupLayout.PREFERRED_SIZE)))
				.addComponent(textField, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(jButton2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
				    .addComponent(jButton1, GroupLayout.Alignment.BASELINE, 0, 37, Short.MAX_VALUE))
				.addContainerGap());
			pack();
			this.setSize(817, 369);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
